package org.spring.springboot.service.impl;

import java.util.List;

import org.spring.springboot.dao.CityDao;
import org.spring.springboot.domain.City;
import org.spring.springboot.service.CityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class CityServiceImpl implements CityService {

    @Autowired
    private CityDao cityDao;

    public City findCityByName(String cityName) {
    	City city=cityDao.findByName(cityName);
    	return city;
    }



	@Override
	public List<City> findCityMore(City city) {
		// TODO Auto-generated method stub
		return cityDao.findMore(city);
	}

	@Override
	public List<City> findCityAll() {
		// TODO Auto-generated method stub
		return  cityDao.findAll();
	}

	@Override
	@Transactional
	public int addCities(List<City> cities) {
		return cityDao.addCities(cities);
	}
	@Override
	@Transactional
	public Long addCity(City city)  {
		cityDao.addOne(city);
		return city.getId();
	}



	@Override
	public City getCityById(long id) {
		// TODO Auto-generated method stub
		return cityDao.findById(id);
	}
}
